import { del, get, post } from "@/utils/request";

interface PCountDownDay{
    id?: number;
    title?: string;
    targetTime?: string; // 对应 Java 的 LocalDateTime 类型
}

interface CountDownDayVo extends PCountDownDay{
    nextDays: number
}


// 新增
const countDownDayAdd = async (day: PCountDownDay) => {
    try {
        return await post<any>("/countDownDay/add", day)
    } catch (error) {
        console.error("倒计日新增操作出现问题: ", error);
    }
}
// 修改
const countDownDayUpdate = async (day: PCountDownDay) => {
    try {
        return await post<any>("/countDownDay/update", day)
    } catch (error) {
        console.error("倒计日修改操作出现问题: ", error);
    }
}
// 删除
const countDownDayDel = async (dayId: number) => {
    try {
        return await del<any>("/countDownDay/delete/" + dayId)
    } catch (error) {
        console.error("倒计日删除操作出现问题: ", error);
    }
}

// 按照状态查询
const countDownDayListByStatus = async (status: number) => {
    try {
        return await get<CountDownDayVo[]>("/countDownDay/list/" + status)
    } catch (error) {
        console.error("倒计日查询操作出现问题: ", error);
    }
}
export{
    countDownDayListByStatus as CountDownDayListByStatus,
    countDownDayDel as CountDownDayDel,
    countDownDayUpdate as CountDownDayUpdate,
    countDownDayAdd as CountDownDayAdd
}